<template>
    <div class="process-monitoring-box">
        <commpVxeTable
         :config="dataTableConfig"
         :columns="columnsVxe"
         :formItem="formItem"
         @checkboxChange="checkboxChange"
         ref="acceptanceRegistrationRef"
         @searchEvent="searchEvent"
         @resetEvent="resetEvent"
         >
            <template v-slot:operation_ffsrmc="{row}" data-desc="姓名">
              <span style="padding-right: 21;" v-if="row.fusermc&&row.fusermc.length == 2">
                  <span v-for="(trem,tI) in row.fusermc.split('')" :key="tI" >
                      {{trem}}
                      <span v-if="tI+1 !== row.fusermc.split('').length">&nbsp;&nbsp;</span>
                  </span>
              </span>
              <span style="padding-right: 21;" v-else>{{ row.fusermc }}</span>
            </template>
            <template v-slot:name_fzjjssj="{row}">
                <span>{{row.fzjkssj}}至{{row.fzjjssj}}</span>
                <!-- <span>{{ timeProcessing(row.fzjkssj	) }}-{{ timeProcessing(row.fzjjssj	) }}</span> -->
            </template>
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline" class="search-form" >
                    <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="reviseClick(row)">查看</a-button>
                    </a-form-item>
                </a-form>
            </template>
        </commpVxeTable>
        <register ref="registerRef" :processingData="processingData" @success="success" @reviseClick="reviseClick"/>
        <!-- <batchProcessing ref="batchProcessingRef" :batchData="batchData" @success="success"/> -->

    </div>
</template>
<script>
import assessCheckApi from './service/api'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import blobType from '@/common/blobType'
import moment from 'moment'
import { initHcyNdkp, queryJobByJobId, deleteNdkpFlowJob } from './service/index'
import register from './register.vue'
// import batchProcessing from './batchProcessing.vue'
export default {
    components:{
        commpVxeTable,
        register,
        // batchProcessing
    },
    props:{
        fywflcode:{
            type:String,
            default:'',
            required:false,
        },
        linkName:{
            type:String,
            default:'',
            required:false,
        }
    },
    data(){
        return{
            processingData:{},
            fyearForm:this.$form.createForm(this, { name: 'formNmae' }),
            fyear:moment(new Date()).format('YYYY'),
            formItem:[
                {
                    label: '年度',
                    model: 'fsxmc',
                },{
                    label: '姓名',
                    model: 'fusermc',
                },{
                    label: '工作单位',
                    model: 'fgzdw',
                },

            ],
            columnsVxe:[
            {
                type: 'checkbox',
                width: 60 ,
                fixed: 'left'
            },{
                title: '姓名', //列头显示文字
                field: 'fusermc',
                width: 100,
                titleInterval:true,
                slots: {
                // 使用插槽模板渲染
                    header:'data1_header',
                    default:'operation_ffsrmc',
                },
            },{
                title: '工作单位',
                field: 'fgzdw',
            },{
                title: '年度',
                field: 'fyear',
                width: 100,
                titleInterval:true,
                slots: {
                    header:'data2_header',
                },
            },{
                title: '总结时间',
                field: 'fzjjssj',
                width: 300,
                slots: {
                // 使用插槽模板渲染
                    default: 'name_fzjjssj',
                },
            },{
                title: '操作',
                field: 'id',
                width: 100,
                titleInterval:true,
                slots: {
                // 使用插槽模板渲染
                    header:'data3_header',
                    default: 'operation_btn',
                },
            }],
            dataTableConfig:{
                api: assessCheckApi.flowMyYbJobPage,
                rowId: 'jobid',
                fywflcode:this.fywflcode,
                paramet:{}
            },
            inspectionTime:[],
            rules:{
                fyear: [{
                    type:'number',
                    required: true,
                    message: '请输入年度',
                    trigger: 'blur',
                }],
            },
            checkboxKey:[],
            jobidList:[],
            batchData:{},
            nextNode:''
        }
    },
    watch:{

    },
    mounted(){

    },
    methods:{
        timeProcessing(val){
            if(val){
                val = val.slice(0,11)
            }
            return val
        },
        success(){
            this.$refs.acceptanceRegistrationRef.searchEvent()
            this.jobidList = []
            this.checkboxKey = []
        },
        searchEvent(){//搜索
            //console.log(this.inspectionTime)
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
                fzjkssj:this.inspectionTime[0]?moment(this.inspectionTime[0]).format('YYYY-MM-DD'):'',
                fzjjssj:this.inspectionTime[1]?moment(this.inspectionTime[1]).format('YYYY-MM-DD'):'',
            }
            //console.log(this.dataTableConfig.paramet)
        },
        resetEvent(){//重置
            this.inspectionTime = []
            this.dataTableConfig.paramet = {
                ...this.dataTableConfig.paramet,
                fzjkssj:'',
                fzjjssj:'',
            }

        },
        checkboxChange(val){
            //console.log('选择项',val)
            this.checkboxKey = []
            this.jobidList = []
            this.nextNode = ''
            if(val.length){
                val.forEach(item => {
                    this.checkboxKey.push(item.ndkpid)
                    this.jobidList.push(item.jobid)
                });
                this.nextNode = val[0].fhjmc
            }


        },
        reviseClick(row){//查看
            //console.log(row)
            // processingData
            queryJobByJobId({jobid:row.jobid}).then(res=>{
                if(res.code == 200){
                    //console.log(res)
                    var data = res.result
                    var HandledByOptions = []
                    data.nextNodeDbrList.forEach(item => {
                            item = {
                                value:item.dbrid,
                                label:item.dbr
                            }
                            HandledByOptions.push(item)
                        });
                    this.processingData = {
                        fywflcode:this.fywflcode,
                        jobid:row.jobid,
                        fhjmc:'我的已办',
                        examine: true,
                        ndkpid:data.ndkp.id,
                        fsfcykp:data.ndkp.fsfcykp,
                        fusermc:data.ndkp.fusermc,
                        fgzdw:data.ndkp.fgzdw,
                        fdqssk:data.ndkp.fdqssk,
                        fyear:data.ndkp.fyear,
                        fljzlqk:data.ndkp.fljzlqk,
                        fsjjccs:data.ndkp.fsjjccs,
                        fzxxpcs:data.ndkp.fzxxpcs,
                        fcql:data.ndkp.fcql,
                        fcjjcqk:data.ndkp.fcjjcqk,
                        fcjjxjyqk:data.ndkp.fcjjxjyqk,
                        frcywnlkhqk:data.ndkp.frcywnlkhqk,
                        fgrndzjqk:data.ndkp.fgrndzjqk,
                        fndzhkpjg:data.ndkp.fndzhkpjg,
                        fbz:data.ndkp.fbz,
                        opinion:data.ndkp.opinion,
                        nextNode:data.nextNode,
                        dbrid:data.nextNodeDbrList.length?[data.nextNodeDbrList[0].dbrid]:[],
                        dbridList:HandledByOptions,
                        smgflag:false,
                        fthyj:data.job.fthyj,
                        fzjkssj:data.ndkp.fzjkssj,
                        fzjjssj:data.ndkp.fzjjssj,
                        fjcqyzs:data.ndkp.fjcqyzs,
                        fdrzycs:data.ndkp.fdrzycs,
                        fdrzzcs:data.ndkp.fdrzzcs,
                        fcjpscs:data.ndkp.fcjpscs,
                        fndszbg:data.ndkp.fndszbg,

                        frckhyxcs:data.ndkp.frckhyxcs,
                        frckhyxl:data.ndkp.frckhyxl,
                        frckhhgcs:data.ndkp.frckhhgcs,
                        frckhhgl:data.ndkp.frckhhgl,
                        frckhbhgcs:data.ndkp.frckhbhgcs,
                    }
                    this.$refs.registerRef.getData(this.processingData)
                    this.$refs.registerRef.visible = true
                }
            })
        },
    }
}
</script>
<style lang="less">
.vxe-fyear{
    padding-top: 0 !important;

}
.fyear-box{
    .ant-input-number{
        width: 105px !important;
    }
}
.red-btn{
    border: 1px solid #ed5565 !important;
    background-color: #ed5565 !important;
}
</style>
